Component({
	data: {
		active: 0,
		list: [
			{
				key:'home',
				text: '首页',
				url: '/pages/index/index',
				icon:{
					normal:'/assets/image/tabbar/ic_tabbar_home_unselect.png',
					active:'/assets/image/tabbar/ic_tabbar_home_select.png',
				}
			},
			{
				key:'my',
				text: '我的',
				url: '/pages/my/index',
				icon:{
					normal:'/assets/image/tabbar/ic_tabbar_me_unselect.png',
					active:'/assets/image/tabbar/ic_tabbar_me_select.png',
				}
			},
		]
	},

	methods: {
		onChange(event) {
			const data = this.data.list[event.detail]
			this.setData({ active: event.detail });
			wx.switchTab({
				url: data.url
			});
		},

		init() {
			const page = getCurrentPages().pop();
			this.setData({
				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
			});
		}
	}
});
